package com.atguigu.flink.function;

import org.apache.flink.api.common.functions.FlatMapFunction;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.util.Collector;

/**
 * Created by Smexy on 2022/12/10
 *
 *  接口外部类实现
 */
public class MyFlatMapFunction implements FlatMapFunction<String, Tuple2<String,Integer>>
{
    @Override
    public void flatMap(String inputLine, Collector<Tuple2<String, Integer>> collector) throws Exception {
        String[] words = inputLine.split(" ");

        for (String word : words) {
            collector.collect(Tuple2.of(word, 1));
        }
    }
}
